package com.mongo.data.utils;

import com.mongo.data.entity.*;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class MissionStatusUtil {


    public MissionStatus getMissionStatus() {

        MissionStatus missionStatus = new MissionStatus();
        missionStatus.setName("1111");
        missionStatus.setJobUUID("abc-abc-abc");

        missionStatus.setUploadNode(getUploadNode());

        List<NodeInfo> dataNodes = new ArrayList<>();
        dataNodes.add(getNodeInfo());
        dataNodes.add(getNodeInfo1());
        missionStatus.setDataNodes(dataNodes);
        missionStatus.setBusinessNodes(dataNodes);

        return missionStatus;
    }


    public static UploadNode getUploadNode() {
        UploadNode uploadNode = new UploadNode();
        uploadNode.setName("123");
        uploadNode.setChnName("abc");
        uploadNode.setBeginTime(111L);
        uploadNode.setEndTime(111L);
        uploadNode.setDuration(111L);

        PodInfo podInfo = new PodInfo("12345", "abc-abc");
        uploadNode.setPodInfo(podInfo);

        uploadNode.setJobId("efg-efg");

        DotLog dotLog = new DotLog();
        dotLog.setTime(111L);
        dotLog.setEvent("111");
//        uploadNode.setDotLog(dotLog);

        uploadNode.setProgress(11);
        uploadNode.setStatus("ABC");

        Map<String, String> map = new HashMap<>();
        map.put("111","111");
        map.put("222","222");
        map.put("333", "333");
        uploadNode.setContinuation(map);

        return uploadNode;
    }

    public static NodeInfo getNodeInfo() {

        NodeInfo nodeInfo = new NodeInfo();
        nodeInfo.setName("123");
        nodeInfo.setChnName("abc");

        nodeInfo.setBeginTime(111L);
        nodeInfo.setEndTime(111L);
        nodeInfo.setDuration(111L);

        PodInfo podInfo = new PodInfo("12345", "abc-abc");
        nodeInfo.setPodInfo(podInfo);

        nodeInfo.setJobId("123-abc");

        DotLog dotLog = new DotLog();
        dotLog.setTime(111L);
        dotLog.setEvent("111");
//        nodeInfo.setDotLog(dotLog);

        nodeInfo.setProgress(11);
        nodeInfo.setStatus("RUNNING");

        Map<String, String> map = new HashMap<>();
        map.put("111","111");
        map.put("222","222");
        map.put("333", "333");
        nodeInfo.setContinuation(map);

        Map<String, NodeInfo> nodes = new HashMap<>();
        nodes.put("VIDEO", getChildNodeInfo());
        nodes.put("FUSE", getChildNodeInfo());
        nodes.put("PERCEPTION", getChildNodeInfo());
        nodeInfo.setChildNodes(nodes);
        return nodeInfo;
    }

    public static NodeInfo getNodeInfo1() {

        NodeInfo nodeInfo = new NodeInfo();
        nodeInfo.setName("456");
        nodeInfo.setChnName("abc");

        nodeInfo.setBeginTime(111L);
        nodeInfo.setEndTime(111L);
        nodeInfo.setDuration(111L);

        PodInfo podInfo = new PodInfo("12345", "abc-abc");
        nodeInfo.setPodInfo(podInfo);

        nodeInfo.setJobId("123-abc");

        DotLog dotLog = new DotLog();
        dotLog.setTime(111L);
        dotLog.setEvent("111");
//        nodeInfo.setDotLog(dotLog);

        nodeInfo.setProgress(11);
        nodeInfo.setStatus("RUNNINGGGG");

        Map<String, String> map = new HashMap<>();
        map.put("111","111");
        map.put("222","222");
        map.put("333", "333");
        nodeInfo.setContinuation(map);

        Map<String, NodeInfo> nodes = new HashMap<>();
        nodes.put("abc", getChildNodeInfo());
        nodes.put("aaa", getChildNodeInfo());
        nodes.put("bbb", getChildNodeInfo());
        nodeInfo.setChildNodes(nodes);
        return nodeInfo;
    }

    public static NodeInfo getChildNodeInfo() {
        NodeInfo nodeInfo = new NodeInfo();
        nodeInfo.setStatus("finish");
        nodeInfo.setBeginTime(100L);
        nodeInfo.setEndTime(200L);
        nodeInfo.setDuration(100L);
        return nodeInfo;
    }




}
